package nuitInfo.android;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import com.json.entity.IconifiedText;
import com.json.entity.IconifiedTextListAdapter;
import com.json.entity.JSONRead;
import com.json.entity.Results;

import android.R.drawable;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class GiftAndroidJSONActivity extends ListActivity {

	private IconifiedTextListAdapter itla;
	public static Results itemSelect;
	private List<Results> listKDO;
	public static View vue;
	private String token, id;
	
	public void onCreate(Bundle icicle) {
		
		Intent thisIntent = getIntent();
	    token = thisIntent.getExtras().getString("token");
	    id = thisIntent.getExtras().getString("id");
	    
		listKDO = (new JSONRead()).loadJSON(token, id);

		super.onCreate(icicle);

		// Création de la liste
		itla = new IconifiedTextListAdapter(this);
		
		for (int i = 0; i < listKDO.size(); i++) {

			// Création élément liste
			IconifiedText icon = new IconifiedText(listKDO.get(i));

			// Ajout de l'élément.
			itla.addItem(icon);
		}

		// Display it
		setListAdapter(itla);
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {

		this.vue = v;
		itemSelect = listKDO.get(position);
		
		Intent intent = new Intent(this, 
				GiftDescription.class); 
		startActivity(intent);
	}
}